package org.huangrui.spark.java.sql;

import org.apache.spark.sql.SparkSession;

/**
 * @Author hr
 * @Create 2024-10-20 20:35
 */
public class SparkSQL08_Source_Hive {
    public static void main(String[] args) {
        // TODO 在编码前，设定Hadoop的访问用户
        System.setProperty("HADOOP_USER_NAME","huangrui");
        // TODO 启用Hive的支持
        SparkSession spark = SparkSession.builder().enableHiveSupport().appName("SparkSQL08_Source_Hive").master("local[2]").getOrCreate();
        spark.sql("show tables").show();

        // spark.sql("create table user_info(name String,age bigint)");
        // spark.sql("insert into table user_info values('zhangsan',10)");
        spark.sql("select * from student").show();

        spark.stop();
    }
}
